package com.wanlian.router.app;

import android.app.Activity;
import android.app.Application;
import android.os.Bundle;

import com.smart.android.utils.Logger;
import com.smart.android.utils.Utils;
import com.umeng.analytics.MobclickAgent;
import com.umeng.commonsdk.UMConfigure;
import com.wanlian.router.BuildConfig;
import com.wanlian.router.Frame;
import com.wanlian.router.net.NetWorkingClient;
import com.wanlian.router.net.internal.BaseHttpClient;


import cn.jpush.android.api.JPushInterface;

/**
 * Created by Hyu on 2018/8/26.
 * Email: fvaryu@qq.com
 */
public class AppContext extends Application implements Application.ActivityLifecycleCallbacks{

    @Override
    public void onCreate() {
        super.onCreate();

        Utils.init(this, BuildConfig.DEBUG);

        Frame.getInstance().init(this);
        NetWorkingClient.getInstance().init(
                new BaseHttpClient.Builder()
                .domain("http://47.75.195.106/router")
                .withLog(true)

        );

        JPushInterface.setDebugMode(BuildConfig.DEBUG);
        JPushInterface.init(this);

        UMConfigure.setLogEnabled(BuildConfig.DEBUG);
        UMConfigure.init(this, UMConfigure.DEVICE_TYPE_PHONE, "5bbace78f1f5568143000074");


        registerActivityLifecycleCallbacks(this);
    }

    @Override
    public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
        Logger.i(String.format("onCreated >> %s", activity.toString()));
    }

    @Override
    public void onActivityStarted(Activity activity) {
        Logger.i(String.format("onStart >> %s", activity.toString()));
    }

    @Override
    public void onActivityResumed(Activity activity) {
        MobclickAgent.onResume(activity);
        Logger.i(String.format("onResume >> %s", activity.toString()));
    }

    @Override
    public void onActivityPaused(Activity activity) {
        MobclickAgent.onPause(activity);
        Logger.i(String.format("onPause >> %s", activity.toString()));
    }

    @Override
    public void onActivityStopped(Activity activity) {
        Logger.i(String.format("onStop >> %s", activity.toString()));
    }

    @Override
    public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
        Logger.i(String.format("onCreated >> %s", activity.toString()));
    }

    @Override
    public void onActivityDestroyed(Activity activity) {
        Logger.i(String.format("onDestroy >> %s", activity.toString()));
    }
}
